From: Rob Church Date: Wed, 4 Jan 2006 13:02:04 +0000 (+0000) Subject: Tweak script to allow just reporting of the number of inactive accounts X-Git-Tag: 1.6.0~773 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=bd5588a44571e6a6f8feb05d169c790aa23957c7;p=lhc%2Fweb%2Fwiklou.git Tweak script to allow just reporting of the number of inactive accounts --- diff --git a/maintenance/removeUnusedAccounts.inc b/maintenance/removeUnusedAccounts.inc index ac3b5c4ebc..74f5420cb9 100644 --- a/maintenance/removeUnusedAccounts.inc +++ b/maintenance/removeUnusedAccounts.inc @@ -8,6 +8,9 @@ * @author Rob Church */ +define( 'ACTION_REPORT', 0 ); +define( 'ACTION_DELETE', 1 ); + # Count the number of edits the specified user has made function CountEdits( $user_id ) { # We've *got* to pull this stuff off the master. If the user *has* made an edit, but it hasn't diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index dd9214f0d4..038875f4d9 100644 --- a/maintenance/removeUnusedAccounts.php +++ b/maintenance/removeUnusedAccounts.php @@ -12,13 +12,26 @@ require_once( 'commandLine.inc' ); require_once( 'removeUnusedAccounts.inc' ); echo( "REMOVE UNUSED ACCOUNTS\nThis script will delete all users who have made no edits.\n\n" ); +echo( "Syntax: removeUnusedAccounts.php [delete]\n * delete -> delete the accounts\n * The first user (usually the site owner) is left alone\n\n" ); + +# Handle parameters +if( isset( $args[0] ) ) { + $param = array_shift( $args ); + if( $param == 'delete' ) { + $action = ACTION_DELETE; + } else { + $action = ACTION_REPORT; + } +} else { + $action = ACTION_REPORT; +} $count = 0; $del = array(); # Right, who needs deleting? $users = GetUsers(); -echo( "Found " . count( $users ) . " accounts.\n" ); +echo( "Found " . count( $users ) . " accounts.\n\n" ); echo( "Locating inactive users..." ); foreach( $users as $user ) { if( $user != 1 ) { # Don't *touch* the first user account, ever @@ -32,11 +45,11 @@ foreach( $users as $user ) { echo( "done.\n" ); # Purge the inactive accounts we found -echo( $count . " inactive accounts found. Deleting..." ); -DeleteUsers( $del ); -echo( "done.\n" ); - -# We're done -echo( "Complete.\n" ); +echo( $count . " inactive accounts found." ); +if( ( $action == ACTION_DELETE ) && ( $count > 0 ) ) { + echo( " Deleting..." ); + DeleteUsers( $del ); + echo( "done.\n" ); +} ?> \ No newline at end of file